import requests
import time
headers={
    'Accept':'text/html, application/xhtml+xml,application/xml；q= 0. 9,image/webp,image/apng,*/* ；q=0. 8,application/signed-exchange;v =b3',
    'Accept-Encoding':'gzip,deflate',
    'Accept-Language':'zh-CN,zh;q=0.9',
    'User-Agent':'Mozilla/5.0 ( Windows NT 10.0;Win64;x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/74.0.3729.108 Safari/537.36'
}
def get_dydata(i):
    url='https://www.job5156.com/s/result/ajax.json? keyword=&keywordType= O&posTypeList =&locationList=14010000% 2C14030000%2C14020000&taoLabelList = &degreeFrom =&propertyList =&industiyList= &sortBy = O&urgentFlag = &maxSalary = &salary = &workyearFrom = &workyearTo =&degreeTo=&pageNo= {}'.format(i)
    response=requests.get(url,headers=headers).text
    response=response.replace('null','None').replace('false','False').replace('true','True')
    response=eval(response)
    for a in response['page']['items']:
        comname=a['comName']
        addr=a['workLocationsStr']
        if a['educationDegreeStr']=="":
            req=a['reqWorkYearStr']
        else:
            r1=a['educationDegreeStr']
            r2=a['reqWorkYearStr']
        salary=a['salaryStr']
        name=a['posName'].replace('<em><em>',"").replace('</em></em>',"")
        desc=a['industryStr']
        print(comname,addr,req,salary,name,desc)
if __name__=='__main__':
    for i in range(1,200):
        get_dydata(i)
        time.sleep(1)

